import sys
from PyQt5.QtWidgets import (
    QApplication, QMainWindow, QLabel, QPushButton, QVBoxLayout, QHBoxLayout,
    QWidget, QLineEdit, QFormLayout, QFrame, QDesktopWidget
)
from PyQt5.QtCore import Qt

class LoginUI(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setup_ui()
        
    def setup_ui(self):
        self.setWindowTitle("智慧战场目标检测系统 - 用户登录")
        self.setFixedSize(1280, 800)
        self.setStyleSheet("background-color: #2B3E50;")

        # 主布局
        main_layout = QVBoxLayout()

        # 项目标题
        project_title = QLabel("🔹 智慧战场目标检测系统 🔹")
        project_title.setAlignment(Qt.AlignCenter)
        project_title.setStyleSheet("""
            font-size: 34px;
            font-weight: bold;
            color: #FFD700;
            text-shadow: 2px 2px 4px black;
            padding: 10px;
        """)
        main_layout.addWidget(project_title)

        # 中心登录框
        center_frame = QFrame()
        center_frame.setStyleSheet("""
            background-color: #2B3E50;
            border: 2px solid #556B2F;
            border-radius: 10px;
        """)
        center_frame.setFixedSize(400, 300)

        # 登录框布局
        center_layout = QVBoxLayout()

        # 登录标题
        title_label = QLabel("用户登录")
        title_label.setAlignment(Qt.AlignCenter)
        title_label.setStyleSheet("""
            font-size: 24px;
            font-weight: bold;
            color: white;
            text-shadow: 2px 2px 2px black;
        """)
        center_layout.addWidget(title_label)

        # 表单布局
        form_layout = QFormLayout()

        # 账号输入框
        self.username_input = QLineEdit()
        self.username_input.setPlaceholderText("请输入账号")
        self.username_input.setStyleSheet("""
            background-color: #2F4F4F;
            color: white;
            font-weight: bold;
            border: 2px solid black;
            padding: 5px;
            border-radius: 5px;
        """)
        form_layout.addRow(QLabel("账号:"), self.username_input)

        # 密码输入框
        self.password_input = QLineEdit()
        self.password_input.setPlaceholderText("请输入密码")
        self.password_input.setEchoMode(QLineEdit.Password)
        self.password_input.setStyleSheet("""
            background-color: #2F4F4F;
            color: white;
            font-weight: bold;
            border: 2px solid black;
            padding: 5px;
            border-radius: 5px;
        """)
        form_layout.addRow(QLabel("密码:"), self.password_input)

        # 设置标签样式
        form_layout.labelForField(self.username_input).setStyleSheet("color: white; font-weight: bold;")
        form_layout.labelForField(self.password_input).setStyleSheet("color: white; font-weight: bold;")

        center_layout.addLayout(form_layout)

        # 登录按钮
        self.login_button = QPushButton("登录")
        self.login_button.setStyleSheet("""
            background-color: #2F4F4F;
            color: white;
            font-weight: bold;
            border: 2px solid black;
            padding: 10px;
            border-radius: 5px;
            text-shadow: 1px 1px 1px black;
        """)
        center_layout.addWidget(self.login_button)

        # 设置小框的布局
        center_frame.setLayout(center_layout)

        # 将小框居中显示
        main_layout.addStretch()
        main_layout.addWidget(center_frame, alignment=Qt.AlignCenter)
        main_layout.addStretch()

        # 设置主窗口的中心部件
        central_widget = QWidget()
        central_widget.setLayout(main_layout)
        self.setCentralWidget(central_widget)

        # 窗口居中
        self.center()

    def center(self):
        """将窗口居中显示"""
        screen = QDesktopWidget().screenGeometry()
        size = self.geometry()
        self.move((screen.width() - size.width()) // 2, 
                 (screen.height() - size.height()) // 2)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = LoginUI()
    window.show()
    sys.exit(app.exec_()) 